//
//  GCDTimer.h
//  Tools
//
//  Created by han on 2019/1/4.
//  Copyright © 2019 han. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface GCDTimer : NSObject

- (instancetype)initWithInterval:(NSTimeInterval)interval repeats:(BOOL)repeats triggerBlock:(void(^)(void))triggerBlock;
- (void)resume;
- (void)suspend;
- (void)stop;

@end

NS_ASSUME_NONNULL_END

/*
 // usage:
 
 @property (nonatomic, strong) GCDTimer *timer;
 // start
 - (void)startTimer {
 if (!self.timer) {
 __weak typeof (self) weakSelf = self;
 self.timer = [[GCDTimer alloc]initWithInterval:1 repeats:YES triggerBlock:^{
 [weakSelf timerBlock];
 }];
 [self.timer resume];
 }
 }
 // stop
 - (void)stopTimer {
 self.timer = nil;
 }
 */
